﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


using Microsoft.Practices.Prism.PubSubEvents;
using System.Windows;

using EventAggregationModule.Models;
using EventAggregationModule;

namespace Product_1_2
{
    public class InputPresenter
    {
        private IInputView _view;
        private IEventAggregator eventAggregator;

        public InputPresenter(IEventAggregator eventAggregator)
        {
            this.eventAggregator = eventAggregator;
        }

        void Result(object sender, EventArgs e)
        {
            LotNumber lotNumber = new LotNumber();

            lotNumber.Number = View.Number;

            lotNumber.Day = View.Day;

            lotNumber.Month = View.Month;

            lotNumber.Year = View.Year;

            lotNumber.Quantity = View.Quantity;

            //  lotNumber.Number2 = View.Number2;        

            eventAggregator.GetEvent<LotNumberEvent>().Publish(lotNumber);
        }

        public IInputView View
        {
            get { return _view; }
            set
            {
                _view = value;      //view값 setting
                _view.Result += Result;       //tightly-coupled
            }
        }
    }
}
